﻿using Infrastructure.DC;
namespace Application.Task
{
    public class RemoveCustomer
    {
        private readonly ICustomersDao _customersDao;
        private readonly int _id;
        public RemoveCustomer(int id)
            : this(id, new CustomersDao())
        { }
        public RemoveCustomer(int id, ICustomersDao customerDao)
        {
            _id = id;
            _customersDao = customerDao;
        }
        public void Execute()
        {
            var customer = _customersDao.RetrieveById(_id);
            if (customer != null)
            {
                if (customer.CanBeDeleted)
                {
                    _customersDao.RemoveById(_id);
                }
            }

        }
    }
}
